-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BASE_URL environment configuration #529
Conversation
Signed-off-by: dodo920306 <[email protected]>
Signed-off-by: dodo920306 <[email protected]>
@@ -9,6 +9,13 @@ nginx -v | |||
export GIN_MODE=release | |||
/opt/service/ivory & | |||
|
|||
# insert base url | |||
envsubst '\$BASE_URL' < /etc/nginx/nginx.conf > "/etc/nginx/nginx.conf.tmp" && mv "/etc/nginx/nginx.conf.tmp" "/etc/nginx/nginx.conf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh, I don't like this solution, I was checking as well how to do it better, the main problem that nginx doesn't work with env variables, I want to check if there is more elegant way to do this. I'm even thinking changing nginx 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I understand. It's a little bit awkward, but even Nginx themself use envsubst
in their images.
Anyway, I'm also wondering if there is a better solution🤔.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and there is one more problem that even when we have relative path in html, it doesn't work properly with trailing slash, to work it correctly we need to add <base>
element with this url
. I'm trying to do it right now will see. I will share the changes with a bit later today probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't work properly with trailing slash
I don't get it, but I guess I'll see it in the changes👍.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to get rid of nginx and use go server, I wanted it to do long time ago, because it will help to ease setup of TLS and usage of http/2. You can check it here #530 I will release it under 1.3.4.
P.S. Thanks for you effort, your comments were useful, it helped me to know something new, hope you as well :)
P.S.S I will close this PR
Won't be merge, because of another solution #530 |
Make API URL also relative and insert BASE_URL into Nginx configuration so that it can fully work with proxies.
One can create Ivory container by a command like
docker run -d -e BASE_URL="/ivory" -p 80:80 --restart unless-stopped aelsergeev/ivory
to make it work under/ivory
or any other give url. It can also still works even if the variable hasn't been assigned, but once it's assigned, it must start with a slash '/'.Notice that
nginx.conf
has been changed to rewrite the api request path, which causes it now can't be used directly withoutenvsubst
.